import { ref, computed } from 'vue'

export function useNavSize() {
	//  状态栏的高度(安全区)
	const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
	// 自定义navBar的高度
	const titleBarHeight = computed(() => {
		// 小程序
		// #ifdef MP
		const { top, height } = uni.getMenuButtonBoundingClientRect()
		return (top - statusBarHeight.value) * 2 + height
		// #endif
		// 小程序除外
		// #ifndef MP
		return 45
		// #endif
	})
	// 状态栏和自定义navBar总高度
	const navBarHeight = computed(() => statusBarHeight.value + titleBarHeight.value)

	return {
		statusBarHeight,
		titleBarHeight,
		navBarHeight
	}
}
